#include <bits/stdc++.h>
using namespace std;
#define Alshoki ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define endl '\n'
#define ll long long
#define ld long double
#define print(x,z) for(int i = 0 ; i <z; ++i) cout<<x[i]<<" ";
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define wrong cout<<-1<< endl ; return ;
bool pairSort(pair<int,int> & a , pair<int,int> & b){
return a.second <= b.second;
}
vector<int> factors(int m){
vector<int> v;
for (int i = 1; i <= sqrt(m) ; ++i) {
if(m% i == 0){
v.push_back(i);
if(m/i != i)
v.push_back(m/i);
}
}
sort(v.begin(),v.end());
return v ;
}
void primeFactors(int n)
{
int c=2;
while(n>1)
{
if(n%c==0){
cout<<c<<" ";
n/=c;
}
else c++;
}
}
bool good(int cur , int goal){
if(cur == goal )return true;
if(cur<goal) return false;
if(cur % 3 == 0){
int sum = cur / 3;
return good(sum,goal) || good(cur-sum,goal);
}
return false;
}
void solve(){
int n , m; cin >> n >> m;
int ans_x = 0 , ans_y = 0;
int freq[300] = {0};
for (int i = 0; i < m; ++i) {
int x , y ; cin >> x >> y;
freq[x]++;
freq[y]++;
}
sort(freq,freq+300,greater<int>());
if(freq[0] == freq[1]) ans_y = freq[0];
else{
ans_x = freq[0];
ans_y = freq[1];
}
for (int i = 1; i < 300 ; ++i) {
if(freq[i] != freq[i-1]){
if(ans_x == 0 && freq[i]!= 1) {
ans_x = freq[i];
break;
}
}
}
if(ans_x == 0) ans_x = ans_y;
cout << ans_x << ' ' << ans_y - 1 << endl;
}
int main() {
Alshoki
ll t = 1;
cin>>t;
while(t--){
solve();
}
}
1290. Convert Binary Number in a Linked List to Integer | 1525. Number of Good Ways to Split a String |
72. Edit Distance | 563. Binary Tree Tilt |
1306. Jump Game III | 236. Lowest Common Ancestor of a Binary Tree |
790. Domino and Tromino Tiling | 878. Nth Magical Number |
2099. Find Subsequence of Length K With the Largest Sum | 1608A - Find Array |
416. Partition Equal Subset Sum | 1446. Consecutive Characters |
1618A - Polycarp and Sums of Subsequences | 1618B - Missing Bigram |
938. Range Sum of BST | 147. Insertion Sort List |
310. Minimum Height Trees | 2110. Number of Smooth Descent Periods of a Stock |
2109. Adding Spaces to a String | 2108. Find First Palindromic String in the Array |
394. Decode String | 902. Numbers At Most N Given Digit Set |
221. Maximal Square | 1200. Minimum Absolute Difference |
1619B - Squares and Cubes | 1619A - Square String |
1629B - GCD Arrays | 1629A - Download More RAM |
1629C - Meximum Array | 1629D - Peculiar Movie Preferences |